{extend name="public/base" /} 
{block name="style"}
	<link href="__CSS__/cash.css" rel="stylesheet">	
	<link href="__CSS__/jqgrid.css" rel="stylesheet">	
	<style>
		.s_active{
			background-color: #0D8DDB;
			color: #fff;
			font-size: 14px;
		}
		.m_input{
			width: 50px!important;
		    text-align: center;
		    height: 30px;
		    border: 1px solid #EEE;
		    -webkit-border-radius: 0!important;
		    -moz-border-radius: 0!important;
		    border-radius: 0!important;
		    line-height: 28px!important;
		}
		.sk_table tr td{
			border: 1px #e7eaec solid;height:40px;line-height:40px;
			text-align: center;
		}
	</style>
{/block}
{block name="body"}
<div class=" gray-bg" data-scroll="y" data-scroll-destroy="true" id="container" scroll="true">
	<div id="gd_box" class="ibox-content" style="width:47%;height:500px;float: left;margin-top: 20px;margin-left: 20px;">
		<div class="  animated fadeInRight">
			<div class="input-group m-b">
                <div class="input-group-btn">
                    <button tabindex="-1" id="goods_type"  class="btn btn-white s_active" type="button">商品分类</button>
                    <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" aria-expanded="false"><span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                    	 <li data-id="0" data-name="全部分类"><a>全部分类</a>
                      	{foreach name="types" id="tp"}
                      	 <li data-id="{$tp.id}" data-name="{$tp.name}"><a>{$tp.name}</a>
                       	 </li>
                      	{/foreach}
                    </ul>
                </div>
                <div class="input-group-btn">
                    <button tabindex="-1" onclick="change_box(this,'pk_box','gd_box')" class="btn btn-white" type="button">商品套餐</button>
                </div>
                <input type="text" id="skey" class="form-control" placeholder="搜索商品编号或名称" >
                  <span class="input-group-addon" > <img  onclick="get_goods_list(null);" src="__IMG__/search.png" /></span>
            </div>
  			</div>
  			 <table class="table  table-hover tcash">
                <thead>
                    <tr class="long-tr text-center">
                    	<th>商品编号</th>
                        <th>名称</th>
                        <th>库存</th>
                        <th>单价</th>
                        <th>单位</th>
                        <th>操作</th>
                    </tr>
                </thead>
             </table>
             <div style="overflow-y: scroll;height: 400px;">
            <table class="table">
                <tbody id="goods_list" class="text-center">
                	{volist name="goods" id='gd'}
                	<tr class="long-tr">
                	<td>{$gd.goods_no}</td>
                	<td>{$gd.goods_name}</td>
                	<td>{$gd.stock}</td>
                	<td>{$gd.sale_price}</td>
                	<td>{$gd.unit}</td>
                	<td><span data-price="{$gd.sale_price}" data-stock="{$gd.stock}" data-id="{$gd.id}" data-no="{$gd.goods_no}" data-name="{$gd.goods_name}" style="font-size: 24px" onclick="select_goods(this,1)">+</span></td>
                	</tr>
                	{/volist}
                </tbody>
            </table>
            </div>
            </div>
	<div id="pk_box" class="ibox-content" style="display:none;width:47%;height:500px;float: left;margin-top: 20px;margin-left: 20px;">
			<div class="  animated fadeInRight">
				<div class="input-group m-b">
	                <div class="input-group-btn">
	                    <button tabindex="-1" onclick="change_box(this,'gd_box','pk_box')" class="btn btn-white " type="button">商品分类</button>
	                    <button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button" aria-expanded="false"><span class="caret"></span>
	                    </button>
	                    <ul class="dropdown-menu">
	                      	{foreach name="types" id="tp"}
	                      	 <li><a>{$tp.name}</a>
	                       	 </li>
	                      	{/foreach}
	                    </ul>
	                </div>
	                <div class="input-group-btn">
	                    <button tabindex="-1"  class="btn btn-white s_active" type="button">商品套餐</button>
	                </div>
	                <input type="text" class="form-control" placeholder="搜索套餐编号或名称" >
	                  <span class="input-group-addon" > <img src="__IMG__/search.png" /></span>
	            </div>
	  			</div>
	  		<table class="table  table-hover tcash">
                <thead>
                      <tr class="long-tr text-center">
	                    	<th>套餐编号</th>
	                        <th>名称</th>
	                        <th>单价</th>
	                        <th>单位</th>
	                        <th>操作</th>
	                    </tr>
                </thead>
             </table>
             <div style="overflow-y: scroll;height: 400px;">
	            <table class="table  table-hover">
	                <tbody id="list" class=" text-center">
	                	{volist name="packges" id='pk'}
	                	<tr id="pk_{$pk.id}">
	                	<td>{$pk.package_no}</td>
	                	<td>{$pk.package_name}</td>
	                	<td>{$pk.package_price}</td>
	                	<td>{$pk.unit}</td>
	                	<td><span data-goods="{$pk.goods_names}" data-name="{$pk.package_name}" data-price="{$pk.package_price}"data-no="{$pk.package_no}"  data-id="{$pk.id}" style="font-size: 24px" onclick="select_goods(this,2)">+</span></td>
	                	</tr>
	                	{/volist}
	                </tbody>
	            </table>
	            </div>
	            </div>
		
	<div id="pk_box" class="ibox-content" style="width:47%;height:500px;display:inline-block;margin-top: 20px;margin-left: 20px;">
			<div class="  animated fadeInRight">
				<div class="input-group m-b" style="width:100%;text-align: center;">
	               <span class="b_rs_pan" style="font-size: 24px;float: left;">金额:&nbsp;&nbsp;&nbsp;</span><span   style="float: left;color: red;">￥<span id="total_price" style="color: red;" class="b_rs_pan">0</span></span> <span class="b_rs_pan" >商品/套餐列表</span>
	            </div>
	  			</div>
	  		<table class="table  table-hover tcash">
                <thead>
                      <tr class="long-tr text-center">
	                    	<th>名称</th>
	                        <th >单价</th>
	                        <th >数量</th>
	                        <th >小计</th>
	                        <th >操作</th>
	                    </tr>
                </thead>
             </table>
             <div style="overflow-y: scroll;height: 400px;">
	            <table class="table  table-hover">
	                <tbody id="goods_cart" class=" text-left">
	                	
	                </tbody>
	            </table>
	            </div>
	            </div>
</div>
<div class=" gray-bg" data-scroll="y" data-scroll-destroy="true" id="container1" style="display: none;" scroll="true">
<div class="ibox float-e-margins" style="width:47%;float: left;margin-top: 5px;margin-left: 20px;">
		<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="input-group m-b">
		        <input type="text" id="key" name="key" class="form-control" placeholder="搜索会员卡号/手机号/姓名">
		        <span class="input-group-addon" > <img src="__IMG__/search.png" /></span>
		        <span class="input-group-addon" onclick="adduser()"><img src="__IMG__/adduser.png" /></span>
		    </div>
  		</div>
  		<div  id="member_info" style="display: none;" >
			<p><span class="m_rs_pan ">会员卡号:</span><span id="no"></span><span class="card_type"></span></p>
			<p><span class="m_rs_pan ">姓名:<span id="name"></span></span>
			   <span class="m_rs_pan r1">手机号:<span id="mobile"></span></span>
			   <span class="m_rs_pan r1">余额:<span id="money"></span></span>
			    <span class="m_rs_pan r1">积分:<span id="score"></span></span>
			</p>
  		</div>
 		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">账单金额<span class="m_rs_pan">(元)</span></span>
		        <input onkeyup="keyup_price(this)" readonly="readonly" type="text" id="price" class="form-control rs_input" placeholder="0.00￥"> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">折后金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" id="zhe_price" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="rs_pan">赠送积分</span>
		        <input type="text" id="zs_score" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="b_rs_pan">应收金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" id="ys_money" readonly="readonly" class="form-control rs_input" placeholder=""> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		       <button onclick="search_emp()" tabindex="-1" class="btn btn-white" type="button"><i class="fa fa-plus"></i>选择导购</button>
		       <br />
		       <div  id="emp_info"  style="display: none;">
				<p><span class="m_rs_pan ">导购员工号:<span id="zno"></span></span>
				   <span class="m_rs_pan r1">职务:<span id="zname"></span></span>
				</p>
  			   </div>
                <textarea id="ccomment" name="comment" style="height: 80px;width: 100%;" class="form-control" required="" placeholder="填写备注" aria-required="true"></textarea>
		    </div>
  		</div>
        </div>
  	</div>
	<div  style="width:47%;display:inline-block;float: left;margin-top: 25px;margin-left: 20px;background-color: #fff;">
			<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="input-group m-b" style="width: 100%;margin-bottom: 3px;">
		         <div style="float:left"><span class="b_rs_pan" >支付方式?</span></div>
		        <div style="float:right;margin-right: 30px;"> 找零:<span style="float:right;margin-right: 25px;" class="rs_pan" id="zhaoling" ></span></div>
		    </div>
  		</div>
 		<div class="row line" style="padding-bottom: 3px;" ></div>
		<div class="" >
			<ul class="nav pay_method">
				<li class="sku" onClick="switch_spec(this)" data = "1">
					<p><img src="__IMG__/pay.png"/></p>
					<p><span class="p_name">现金</span></p>
					<s></s>
				</li>
				<li class="sku " onClick="switch_spec(this)" data = "2">
					<p><img src="__IMG__/coupon.png"/></p>
					<p><span class="p_name">会员卡</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)" data = "3">
					<p><img src="__IMG__/weixin.png" /></p>
					<p><span class="p_name">微信</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)" data = "4">
					<p><img src="__IMG__/alipay.png"/></p>
					<p><span class="p_name">支付宝</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)" data = "5">
					<p><img src="__IMG__/bank.png"/></p>
					<p><span class="p_name">银联</span></p>
					<s></s>
				</li>
				<li class="sku" onClick="switch_spec(this)">
					<p><img src="__IMG__/card.png"/></p>
					<p><span class="p_name">自定义</span></p>
					<s></s>
				</li>
			</ul>
  		</div>
  		<div class="row line" style="margin-top: 5px;"></div>
  		<div class="row" style="margin-left: 10px;height:25px;line-height: 25px;">
                <div onclick="select_juan()" style="display: inline;"><i class="fa fa-plus"></i>优惠券</div>
                <div id="coupon_juan" style="display: inline-block;padding-left: 20px;"></div>
  		</div>
  		<div class="row line" ></div>
  		<div class="row" >
			<div class="input-group m-b" style="width: 100%;">
		        <span class="b_rs_pan">付款金额<span class="m_rs_pan">(元)</span></span>
		        <input type="text" onkeyup="keyup_pay(this)" id="pay_money" class="form-control rs_input1 " placeholder="0.00￥"> 
		    </div>
  		</div>
  		<div class="row line" ></div>
		<div class="row" style="margin-left: 20px;">
            <button class="btn btn-primary p-btn" type="button" onclick="confirm_sk()">确定收款</button>
            <button class="btn btn-white p-btn" type="button" onclick="$('#container').show();$('#container1').hide();$('#menu_bottom').show();">返回</button>
        </div>
		</div>
  		<input  type="hidden" name="pay_method" id="pay_method" />
  		<input type="hidden" name="dg_empno" id="dg_empno" />
  		<input type="hidden" name="line_member_id" id="line_member_id" />
	</div>
</div>
<div class="row" id="menu_bottom" style="z-index:100;width:100%;margin-left: 20px;position: absolute;bottom: 30px;background-color: #CCCCCC;">
	<span><button class="btn btn-primary p-btn" type="button" onclick="guadan()">挂单</button>
	<button class="btn btn-primary p-btn" type="button" onclick="jiegua()">解挂</button>
	</span>
	<span style="margin-left:250px;">
    <button class="btn btn-primary p-btn" style="background-color: #CA4440;" type="button" onclick="sk()">收款</button>
    <button class="btn btn-white p-btn" type="button" onclick="reset_gd()">清空</button>
    </span>
</div>
{/block} {block name="script"}
<script src="__JS__/cash.js"></script>
<script>
  	var cartlist={};
  	function sk(){
		var check=check_goods();
		if(check){
			var price=$("#total_price").text();
			$("#container").hide();
			$("#container1").show();
			$("#price").val(price);
			$("#zs_score").val(price);
			$("#zhe_price").val(price);
			$("#ys_money").val(price);
			$("#coupon_juan").html("");
			$(".sku").removeClass('sku-bo-blo'); //   清空勾选图标
			$(".sku").find("s").css("display","none");  
			$("#pay_money").val("");
			$("#menu_bottom").hide();
		}
  	}
	function check_goods(){
		if($.isEmptyObject(cartlist)){
			layer.msg("您未添加任何购买商品!")
			return false;
		}
		return true;
	}
	function guadan(){
			var check=check_goods();
			if(check){
				show_gd();
			}
	}
	function show_gd(){
		var html='<div class="form-group" id="add_form">'+
			'<div class="input-group col-sm-6">'+
			'<input type="text" id="memo"  placeholder="请输入挂单备注"  class="form-control" style="width: 300px;" />'+
			'<span class="input-group-btn"> <button type="button" onclick="confirm_gd()" class="btn btn-primary">确定</button> </span>'+
			'</div></div>';
			var index=layer.open({
			title:false,
			zIndex :1999,
			btn:false,
		 	area: ['400px', '100px'] ,
			content: html,
			yes: function(index, layero){
			        layer.msg("111");
			}
		});
	}
	function confirm_gd(){
				var memo=$("#memo").val();
				var total_price=parseFloat($("#total_price").text());
				var data={"memo":memo,"price":total_price,"data":cartlist}
				$.ajax({
					url:'guadan',
					data:data,
					type:"post",
					success: function(data) {
						if(data==1){
							layer.msg("挂单成功");
							reset_gd();
						}else{
							layer.msg("挂单失败");
						}
					}
				})
	}
	//清空挂单
	function reset_gd(){
		cartlist={};
		$("#total_price").text(0);
		$("#goods_cart").html("");
	}
	function jiegua(){
		if(!$.isEmptyObject(cartlist)){
			layer.msg("购物车有商品不能解挂")
			return false;
		}
		$.ajax({
			url:'get_orders',
			data:{"status":1},
			type:"post",
			success: function(data) {
				var list=data.list;
				var html='<div><table class="sk_table" style="width: 100%;">';
				if(list!=null){
					for(var i in list){
						var order=list[i];
						var item=order.items;
						var name="";
						for(var c in item){
							var o_item=item[c];
							name+=o_item['name']+"*"+o_item['num']+"&nbsp;&nbsp;";
						}
						html+='<tr ><td width="150px">'+order.add_time+'</td><td>'+name+"￥"+order.price+'备注:'+order.memo+'操作员:'+order.emp_id+'</td>'+
						'<td><button type="button" onclick="jiegua_order('+order.id+')" class="btn  btn-success">解挂</button><button type="button" onclick="del_order('+order.id+')" class="btn  btn-white">删除</button></td></tr>';
					}
				}else{
					html+='<tr ><td>没有挂单！</td>'+
						'</tr>';
					}
				html+="</table></div>";
				var index=layer.open({
				  title: '解挂',
				  zIndex :1999,
			 	  area: ['750px', '400px'] ,
				  content: html,
				  btn: false
				});
			}
		})
	}
	function jiegua_order(id){
		$.ajax({
			url:'jiegua',
			data:{"id":id},
			type:"post",
			success: function(data) {
				var items=data.list;
				var html="";
				var arr={};
				for(var i=0;i<items.length;i++){
					var item=items[i];
					var goods_names="";
					arr['goods_names']="";
					if(item.type==2){
						goods_names=item['goods_names'];
						arr['goods_names']=goods_names;
					}
					var total_price=parseFloat(item['price'])*parseFloat(item['num']);
					arr['type']=item.type;
					arr['name']=item.name;
					arr['price']=item.price;
					arr['total_price'] =parseFloat(item.num)*parseFloat(item.price);
					arr['num']=item.num;
					arr['sid']=item.sid;
					cartlist[item.id+item.type.toString()]=arr;
					var tr='<tr>'+
					 '<td style="width:130px;">'+item.name+'</br>'+goods_names+'</td>'+
					 '<td style="width:130px;">'+item.price+'</td>'+
					 '<td style="width:130px;"><input data-name='+item.id+item.type+'  id=goods_'+item.id+item.type+'  class="m_input" type="text" value=1 /></td>'+
					 '<td style="width:130px;" id=total_'+item.id+item.type+'>'+item.price+'</td>'+
					 '<td data-name='+item.id+item.type+' style="font-size:16px;width:130px"><span class="zs_pan" data-name='+item.id+item.type+' >赠</span>&nbsp;&nbsp;<span class="del_pan" data-name='+item.id+item.type+' >删</span></td>'+
					 '</tr>';
					 html+=tr;
				}
				$("#total_price").text(total_price);
				$("#goods_cart").append(html);
				setEvent();
				layer.msg("解挂成功");
			}
		})
	}
	function del_order(id){
		layer.confirm('确定删除?', {icon: 3, title:'提示'}, function(index){
		  $.ajax({
				url:'del_order',
				data:{"id":id},
				type:"post",
				success: function(data) {
					layer.msg("删除成功");
				}
			})
		});
	}
	$(".dropdown-menu li").click(function(){
		var goods_typeid=$(this).attr('data-id');
		$("#goods_type").text($(this).attr('data-name'));
		get_goods_list({'goods_typeid':goods_typeid});
	})
	function get_goods_list(dt){
			if(dt==null){
				var skey=$("#skey").val();
				dt={'key':skey};
			}
			$.ajax({
				url:'get_goods_list',
				data:dt,
				type:"post",
				success: function(data) {
					var html="";
					var res=data.data;
					if(res==null){
						return;
					}
					for(var i=0;i<res.length;i++){
						var gd=res[i];
						var tr='<tr>'+
	                	'<td>'+gd.goods_no+'</td>'+
	                	'<td>'+gd.goods_name+'</td>'+
	                	'<td>'+gd.stock+'</td>'+
	                	'<td>'+gd.sale_price+'</td>'+
	                	'<td>'+gd.unit+'</td>'+
	                	'<td><span data-price="'+gd.sale_price+'" data-stock="'+gd.stock+'" data-id="'+gd.id+'" data-name="'+gd.goods_name+'" style="font-size: 24px" onclick="select_goods(this,1)">+</span></td>'+
	                	'</tr>';
	                	html+=tr;
					}
					$("#goods_list").html(html);
				}
			})
	}
	function setEvent(){
  		$("#goods_cart .m_input").change(function(){
  			change_goods(this);
  		})
  		$("#goods_cart .zs_pan").unbind('click').click(function(){
  			zs_goods(this);
  		})
  		$("#goods_cart .del_pan").unbind('click').click(function(){
  			del_goods(this);
  		})
  	}
	function select_goods(obj,type){
		var goods_names="";
		var arr={};
		if(type==2){
			goods_names=$(obj).attr("data-goods");
			arr['goods_names']=goods_names;
		}else{
			arr['goods_names']="";
		}
		var id=$(obj).attr("data-id");
		var name=$(obj).attr("data-name");
		var price=parseFloat($(obj).attr("data-price"));
		var cart=cartlist[id+type];
		if(cart!=null){
			cartlist[id+type]['total_price']=parseFloat(cartlist[id+type]['total_price'])+parseFloat(price);
			cartlist[id+type]['num']=cartlist[id+type]['num']+1;
		}else{
			arr['type']=type;
			arr['name']=name;
			arr['price']=price;
			arr['total_price']=price;
			arr['num']=1;
			arr['sid']=id;
			arr['is_zs']=0;//是否赠送
			cartlist[id+type]=arr;
		}
		var has=$("#goods_"+id+type);
		if(has.val()==undefined){
			var html='<tr>'+
				 '<td style="width:130px;">'+name+'</br>'+goods_names+'</td>'+
				 '<td style="width:130px;">'+price+'</td>'+
				 '<td style="width:130px;"><input data-name='+id+type+'  id=goods_'+id+type+'  class="m_input" type="text" value=1 /></td>'+
				 '<td style="width:130px;" id=total_'+id+type+'>'+price+'</td>'+
				 '<td data-name='+id+type+' style="font-size:16px;width:130px"><span class="zs_pan" data-name='+id+type+' >赠</span>&nbsp;&nbsp;<span class="del_pan" data-name='+id+type+' >删</span></td>'+
				 '</tr>';
			$("#goods_cart").append(html);
			setEvent();
		}else{
			has.val(parseFloat(has.val())+1);
			$("#total_"+id+type).text(parseFloat($("#total_"+id+type).text())+parseFloat(price));
		}
	 	var total_price=parseFloat($("#total_price").text())+parseFloat(price);
		$("#total_price").text(total_price);
	}
	/**
	 * 赠送商品
	 */
	function zs_goods(obj){
		$(obj).toggleClass("zs_active");
		var ckey=$(obj).data("name");
		$("#total_"+ckey).toggleClass("zs_total");
		var is_zs=cartlist[ckey]["is_zs"];
		var total_price=parseFloat($("#total_price").text());
		if(is_zs==1){
			cartlist[ckey]["is_zs"]=0;
			total_price+=parseFloat(cartlist[ckey]['total_price']);
			$("#total_price").text(total_price);
		}else{
			total_price-=parseFloat(cartlist[ckey]['total_price']);
			$("#total_price").text(total_price);
			cartlist[ckey]["is_zs"]=1;
		}
//		$(obj).parent().parent().remove();
//		layer.close(con);
		
	}
	/**
	 * 删除购物车商品
	 */
	function del_goods(obj){
		var con=layer.confirm('确定删除?', function(index){
			var total_price=parseFloat($("#total_price").text());
			var ckey=$(obj).data("name");
			var is_zs=cartlist[ckey]["is_zs"];
			if(is_zs==0){
				total_price-=parseFloat(cartlist[ckey]['total_price']);
				$("#total_price").text(total_price);
			}
			delete(cartlist[ckey]);
			$(obj).parent().parent().remove();
			layer.close(con);
			
		});
		
	}
	/**
	 * 改变商品数量
	 */
	function change_goods(obj){
		var ckey=$(obj).data("name");
		var num=parseFloat($(obj).val());
		$total_price=num*cartlist[ckey]['price'];
		var total_price1=parseFloat($("#total_price").text());
		var is_zs=cartlist[ckey]["is_zs"];
		if(is_zs==0){
			total_price1+=parseFloat($total_price-parseFloat(cartlist[ckey]['total_price']));
			$("#total_price").text(total_price1);
		}
		cartlist[ckey]['num']=$(obj).val();
		cartlist[ckey]['total_price']=$total_price;
		$("#total_"+ckey).text($total_price);
	}
	function change_box(obj,show,hidden){
		$("#"+show).show();
		$("#"+hidden).hide();
	}

	function confirm_sk(){
		var price=$("#ys_money").val();
		if(price==""||isNaN(price)){
			layer.msg("请输入正确的账单金额!");
			return false;
		}
		var pay_method=$("#pay_method").val();
		if(pay_method==""){
			layer.msg("请选择支付方式!");
			return false;
		}
		var pay_money=$("#pay_money").val();
		if(pay_money==""||isNaN(pay_money)){
			layer.msg("请输入正确的付款金额!");
			return false;
		}
		if(parseFloat(pay_money)<parseFloat(price)){
			layer.msg("付款金额小于账单金额!");
			return false;
		}
		if(pay_method==2){
			if($("#key").val()==""){
				layer.msg("请输入正确的会员卡号!");
				return false;
			}
			var yue=parseFloat($("#money").text());
			if(yue<parseFloat(price)){
				layer.msg("余额不足!");
				return false;
			}
		}
		var coupon_id=$("#counpon_span").attr('data-id');
		if(coupon_id==undefined){
			coupon_id=0;			
		}
		var zhaoling=parseFloat($("#zhaoling").text());
		var html='<div class="row" >'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span id="sp_price" style="font-size:26px;font-weight:600;color:#35b12c">'+price+'</span>'+
							'<p>应收金额</p>'+
						'</div>'+
						'<div style="float: left;width:50%;text-align: center;">'+
							'<span id="sp_zhaoling" style="font-size:26px;font-weight:600;color:red">'+zhaoling+'</span>'+
							'<p>找零</p>'+
						'</div>'+
				   '</div>'+
				   '<div class="row" style="text-align: center;">'+
				   '<p>收银员:godlike</p>'+
				   '</div>';
		var index=layer.open({
		  title: '确认收款',
		  zIndex :1999,
	 	  area: ['500px', '250px'] ,
		  content: html,
		  btn: ['确定','取消'],
		  yes: function(index, layero){
		    //按钮【按钮一】的回调
		    	$.ajax({
					url:'shoukuan',
					data:{coupon_id:coupon_id,type:2,zs_score:$("#zs_score").val(),data:cartlist,price:price,pay_money:pay_money,zhaoling:zhaoling,pay_method:pay_method,dg_id:$("#dg_empno").val(),line_member_id:$("#line_member_id").val()},
					type:"post",
					success: function(dataa) {
						layer.close(index);
							if(pay_method==3||pay_method==4){
								var dt=dataa.data;
								if(pay_method==3){
									var ct='<div style="margin-left:100px;padding:0;"><img alt="扫码支付" src="http://paysdk.weixin.qq.com/example/qrcode.php?data='+dt.code_url+'" style="width:200px;height:200px;"/><div>';
								}else{
									var ct='<div style="margin-left:100px;padding:0;"><img alt="扫码支付" src="'+dt.code_url+'" style="width:200px;height:200px;"/><div>';
								}
								var index1=layer.open({
							 	  area: ['450px', '350px'] ,
							 	  zIndex :1999,
							 	  title:"扫码支付",
								  content: ct,
								  btn: ['支付完成','取消'],
								  yes: function(index, layero){
									  		$.ajax({
									  			type:"post",
									  			url:"confirm_pay",
									  			data:{sn:dt.sn},
									  			success:function(data){
									  				if(data==1){
									  					callback(dataa);
														empty();
									  				}else{
									  					layer.msg("订单支付失败");
									  				}
									  			}
									  		});
								  },btn2:function(index,layero){
								  	layer.close(index1);
								  }
								});
							}else{
								callback(dataa);
								empty();
							}
					}
				})
		  },btn2:function(index,layero){
		  	layer.close(index);
		  }
		});

	}

	
	function callback(data){
		if(data.code==200){
			var info=data.data;
			 var html='<div>'+
					'<div style="text-align: center;">'+
					'<i class="fa fa-check" style="color: #35b12c;font-size: 60px;font-weight: 600;"></i>'+
					'<p><span class="b_rs_pan">收款成功</span> </p>'+
					'</div>'+
					'<div  style="text-align: center;"><span >单号</span><span style="margin-left: 50px;">'+info.sn+'</span></div>'+
					'<div  style="text-align: center;"><span >交易时间</span><span style="margin-left: 50px;">'+info.add_time+'</span></div>'+
					'<div  style="text-align: center;"><span >门店</span><span style="margin-left: 50px;">'+info.store_name+'</span></div>'+
					'<div  style="text-align: center;"><span >操作员</span><span style="margin-left: 50px;">'+info.skr+'</span></div>'+
				 '</div>';
				  var index=layer.open({
				  title: '收款成功',
				  zIndex :1999,
			 	  area: ['600px', '350px'] ,
				  content: html,
				  btn: ['我知道了','打印小票']
				  ,yes: function(index, layero){
				    layer.close(index);
				    $("#container").show();
				    $("#container1").hide();
			    	reset_gd();
				  },btn2:function(index,layero){
				  	$.ajax({
				            type:"POST",
				            url:"print_order",
				            data:{sn:data.data.sn},
				            success:function(dt){
				            }
				        });
				  	$("#container").show();
				    $("#container1").hide();
			    	reset_gd();
				  }
			});
			
		}else{
			layer.msg(data.msg);
			window.reload();
		}
		
	}

	function call_back(msg){
		layer.msg(msg);
		layer.closeAll('iframe');
	}
	

</script>
{/block}